#ifndef UCLCODEH
#define UCLCODEH

#include <iso8583.h>
#include <amexhost.h>
#include <transact.h>
#include "..\cpacsrc\cpac.h"
#include <protocol.h>
#include <packet.h>

#include <applicationobj.h>

#define LANDLINE_COMM	1
#define RS232_COMM		2
#define GSM_COMM		3
#define IP_COMM			4
#define WIFI_COMM		5
#define GPRS_COMM		6
#define CDMA_COMM		7

#define IMAM_UCL

#ifdef IMAM_UCL
typedef struct tagAppObj
{
	ApplicationObj super;
	short (*SetParam)(short paramId, unsigned char *buffer, short size);
}AppObj; 

AppObj *PvsCreateAppObj(short type);

short GetParamLandLine(short paramId, unsigned char *buffer, short size);
short SetParamLandLine(short paramId, unsigned char *buffer, short size);
short GetParamGsm(short paramId, unsigned char *buffer, short size);
short SetParamGsm(short paramId, unsigned char *buffer, short size);
short NotifyLandLine(short state);
short NotifyGsm(short state);

short GetParamCO(short paramId, unsigned char *buffer, short size);
short SetParamCO(short paramId, unsigned char *buffer, short size);
short NotifyCO(short state);

short GetParamWiFi(short paramId, unsigned char *buffer, short size);
short SetParamWiFi(short paramId, unsigned char *buffer, short size);
short NotifyWiFi(short state);

short GetParamGprs(short paramId, unsigned char *buffer, short size);
short SetParamGprs(short paramId, unsigned char *buffer, short size);
short NotifyGprs(short state);

short GetParamCdma(short paramId, unsigned char *buffer, short size);
short SetParamCdma(short paramId, unsigned char *buffer, short size);
short NotifyCdma(short state);

void ShowUclResult(short);

void vdInitializeUclComm (COMM_OBJECT *obCommunication);

int inInitUclCommunication (COMM_OBJECT *obCommunication);
int inBeginUclCommunication (COMM_OBJECT *obCommunication, int inCPTIndex, VS_BOOL fUsePrimaryLine);
int inCheckUclCommunication (COMM_OBJECT *obCommunication);
int inSendUclCommunication (COMM_OBJECT *obCommunication, char *pchSendBuff, int inSendSize, VS_BOOL fConfirmSend, int inTimeout, long lnMessage);
int inReceiveUclCommunication (COMM_OBJECT *obCommunication, char *pchReceiveBuff, int inReceiveSize, int inReceiveTimeout, long lnMessage);
int inFlushUclCommunication (void);
int inEndUclCommunication (COMM_OBJECT *obCommunication);
int inDeInitUclCommunication (COMM_OBJECT *obCommunication);

int inProperlyUclCreate(void);
int inUpdateWirelessStatus(void);
int inHostConnectionTest(void);
unsigned long ulGetConnectionTime(void);
unsigned long ulGetKeepAliveTime(void);
unsigned long ulGetFirstSocketConnectTimeoutTime(void);
int inGetUCLCommLink(void);
int inGetCurrentUCLCommLink(void);
int inGetPPPAuthType(void);
/*
UCL.PARAM=CONNECT_TIME;REGULAR_SOCKET_CONNECT_TIMER;FIRST_CONNECT_TIMEOUT;
0;0;0   ==> never disconnect, never do socket connect, first connect() time out default
30;5;0  ==> connect for 30s; do socket connect every 5 minutes
*/
int inBackGroundWirelessControl(int inMode, int inDesiredStatus);

int inProperlyOpenModem(void);
int inProperlyCloseModem(void);
int inForceCloseModem(void);
int inProperlyCheckRegisterStatus(void);
int inProperlyPPPConnecting(void);
int inProperlyCheckPPPConnecting(void);
int inForcePPPDisconnect(void);
int inProperlySocketConnect(void);
int inProperlySocketDisconnect(void);
int inForceSocketDisconnect(void);
int inPvsSetModemToSleep(void);
int inInitUclCommunication (COMM_OBJECT *obCommunication);

void vdImamDisplayWirelessModemStatus(int inForcedStatus);
int inPing(char *Addr);

int inLoadMinAndAKey(void);


#define MODEM_NOT_OPEN			1000
#define MODEM_OPENED			2000
#define MODEM_REGISTERING		2500
#define MODEM_REGISTERED		3000
#define MODEM_PPP_CONNECTING	3500
#define MODEM_PPP_CONNECTED		4000
#define MODEM_SOCKET_CONNECTED	5000
#endif
#endif 